#include "TB67S109A.h"
#include "wiring_private.h"
using namespace toshiba;
TB67S109A::TB67S109A(tb67s109a_t& driver,ti::SN74AHC595& hc595,smc_clock_callback cb):
    _driver(driver),
    _hc595(hc595),
    _cb(cb),
    _dir(RotationDirection::None)
{
   
}
TB67S109A::~TB67S109A()
{

}
void TB67S109A::begin()
{
   

}
void TB67S109A::set_direction(RotationDirection dir)
{
    _dir = dir;
    _driver.dir = (_dir==RotationDirection::Forward?1:0);
    _hc595.updateRegisters(3);
}
void TB67S109A::enable_clock()
{
    _cb(true);
 //    switch(id)
//     {
//         case DriverID::Motor1:TIMSK1 &= ~(_BV(OCIE1A));break;
//         case DriverID::Motor2:TIMSK1 &= ~(_BV(OCIE1B));break;
//         case DriverID::Motor3:TIMSK2 &= ~(_BV(OCIE2A));break;
//         case DriverID::Motor4:TIMSK2 &= ~(_BV(OCIE2B));break;
//         default:break;
//     }  
}
void TB67S109A::disable_clock()
{
    _cb(false);
//    switch(id)
//     {
//         case DriverID::Motor1:TIMSK1 &= ~(_BV(OCIE1A));break;
//         case DriverID::Motor2:TIMSK1 &= ~(_BV(OCIE1B));break;
//         case DriverID::Motor3:TIMSK2 &= ~(_BV(OCIE2A));break;
//         case DriverID::Motor4:TIMSK2 &= ~(_BV(OCIE2B));break;
//         default:break;
//     }  
}